package com.it.od.old2021.deke1;

import java.util.Scanner;

/**
 * @author: liminghui
 * @date: 2022/8/17 23:52
 * @version: 1.0
 * @description: 如果三个正整数A、B、C , A²+B²=C²则为勾股数
 * 如果ABC之间两两互质，即A与B，A与C，B与C均互质没有公约数，
 * 则称其为勾股数元组。
 * 请求出给定n~m范围内所有的勾股数元组
 * 样例1
 * 输入
 * 1
 * 20
 * 输出
 * 3 4 5
 * 5 12 13
 * 8 15 17
 * 样例2
 * 输入
 * 5
 * 10
 * 输出
 * Na
 *
 */
public class Main1 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        solution(n, m);
    }

    private static void solution(int n, int m) {
        int count = 0;
        for (int a = n; a < m - 1; a++) {
            for (int b = a + 1; b < m; b++) {
                for (int c = b + 1; c < m + 1; c++) {
                    if (relativelyPrime(a, b) &&
                            relativelyPrime(b, c) &&
                            relativelyPrime(a, c) &&
                            a * a + b * b == c * c) {
                        count++;
                        System.out.printf("%d %d %d\n", a, b, c);
                    }
                }
            }
        }
        if (count == 0) {
            System.out.println("Na");
        }
    }

    /**
     * 判断是否是互为质数
     *
     * @param x
     * @param y
     * @return
     */
    private static boolean relativelyPrime(int x, int y) {
        if (x == y && y == 1) {
            return false;
        }
        int min = Math.min(x, y);
        for (int i = 2; i <= min; i++) {
            if (x % i == 0 && y % i == 0) {
                return false;
            }
        }
        return true;
    }
}

